<script setup lang="ts">
import type { Medicine } from '@/types/medicine'

defineProps<{
  medicineArr: Medicine[]
}>()
</script>

<template>
  <div class="head">
    <h3>优医药房</h3>
    <span>优医质保 假一赔十</span>
  </div>
  <div class="medicine" v-for="item in medicineArr" :key="item.id">
    <div class="item van-hairline--top">
      <img :src="item.avatar" width="80" height="70" />
      <div class="info">
        <p class="name">
          <span>{{ item.name }}</span>
          <span class="amount">x{{ item.quantity }}</span>
        </p>
        <p class="size">
          <van-tag type="primary">{{
            item.prescriptionFlag ? '处方药' : '非处方药'
          }}</van-tag>
          <span class="size-info">{{ item.specs }}</span>
        </p>
        <p class="price">￥{{ item.amount }}</p>
      </div>
      <div class="desc">{{ item.usageDosag }}</div>
    </div>
  </div>
</template>

<style lang="scss" scoped>
$price_red: #eb5757;
.head {
  display: flex;
  height: 54px;
  align-items: center;
  h3 {
    font-weight: 400;
    margin-right: 10px;
    font-size: 16px;
  }
  span {
    font-size: 13px;
    color: var(--cp-tag);
  }
}
.medicine {
  .item {
    display: flex;
    flex-wrap: wrap;
    padding: 15px 0;
    .info {
      flex: 1;
      margin-left: 15px;
      .name {
        flex: 1;
        display: flex;
        justify-content: space-between;
      }
      .size {
        margin: 5px 0;
        .size-info {
          color: var(--cp-tag);
          margin-left: 10px;
        }
      }
      .price {
        color: $price_red;
        font-size: 16px;
      }
    }
    .desc {
      width: 100%;
      margin-top: 10px;
      padding: 4px 10px;
      background-color: var(--cp-bg);
      color: var(--cp-tip);
      border-radius: 5px;
    }
  }
}
</style>
